package com.tongcao.cn.config;

import com.tongcao.cn.servlet.ClientApiServlet;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Author:tongcao
 * @Date:2018/8/23 18:15
 * Description:用@Configuration注解该类，等价于XML中配置beans；用@Bean标注方法等价于XML中配置bean。
 */
@Configuration
public class ServlertConfigure {

    /**
     * 代码注册servlet(不需要@ServletComponentScan注解)
     *
     * @return
     */
    @Bean
    public ServletRegistrationBean servletRegistrationBean() {
        // ServletName默认值为首字母小写，即myServlet1
        return new ServletRegistrationBean(new ClientApiServlet(), "/servlet/myServlet1");
    }

}
